import request from "@/utils/request";
import type {
  GetTrademarkListResponse,
  TrademarkItem,
} from "./model/trademarkModel";

enum api {
  getTrademarkList = "/admin/product/baseTrademark",
  removeTrademark = "/admin/product/baseTrademark/remove",
  addTrademark = "admin/product/baseTrademark/save",
  updateTrademark = "/admin/product/baseTrademark/update",
}

/**
 * 新增一条品牌的请求
 * @param data
 * @returns null
 */
export const addTrademark = (data: TrademarkItem) => {
  return request.post<any, null>(api.addTrademark, data);
};

/**
 * 删除一条Logo的请求
 * @param id Logo的id
 * @returns null
 */
export const removeTrademark = (id: number) => {
  return request.delete<any, null>(api.removeTrademark + `/${id}`);
};

/**
 * 修改一条品牌的请求
 * @param data object
 * @returns null
 */
export const updateTrademark = (data: TrademarkItem) => {
  return request.put<any, null>(api.updateTrademark, data);
};

/**
 * 获取商标列表的请求
 * @param page 页码
 * @param limit 每页条数
 * @returns GetTrademarkListResponse
 */
export const getTrademarkList = (page: number, limit: number) => {
  return request.get<any, GetTrademarkListResponse>(
    api.getTrademarkList + `/${page}/${limit}`
  );
};
